﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LockTime
{
    public class FileCtl
    {
        static string path = System.Environment.CurrentDirectory;
        static FileInfo finfo = new FileInfo(path + "\\ini.txt");
        /// <summary>
        /// 读取文件内容
        /// </summary>
        /// <returns></returns>
        public static string LoadFile()
        {
            string timestring = "";
            if(finfo.Exists)
            {
                StreamReader sr = new StreamReader(finfo.FullName, Encoding.UTF8);
                timestring = sr.ReadToEnd();
                sr.Close();
            }
            return timestring;
        }
        /// <summary>
        /// 将字符串写入文件
        /// </summary>
        /// <param name="str"></param>
        public static void SaveFile(string str)
        {
            FileStream fs = new FileStream(finfo.FullName, FileMode.Create, FileAccess.Write);
            StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
            sw.Write(str);
            sw.Close();
        }
    }
}
